package info.decamps.m2settings.model;

import javax.swing.event.TableModelEvent;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;

/**
 * An <code>ExtendableTableModel</code> is a <code>TableModel</code> in whi rows
 * can be added or removed.
 *
 * @author regis
 *
 */
public abstract class ExtendableTableModel extends AbstractTableModel implements TableModel {
    protected String[] columnTitles;
    /**
     * Remove row at the given indexes.
     * @param rowIndexes
     */
    public abstract void removeRows(int[] rowIndexes);
    
    /**
     * Removes the row placed at the given index.
     * @param index
     */
//	/public void removeRow(int index);
    
    /**
     * The descriptive name of the element manipulated by this model.
     */
    public abstract String getElementName();
    
    
    public boolean isCellEditable(int arg0, int arg1) {
        return false;
    }
    
    public int getColumnCount() {
        return columnTitles.length;
    }
    
    public String getColumnName(int index) {
        return columnTitles[index];
    }
    
    public void fireChange(int index) {
        fireTableChanged(new TableModelEvent(this, index, index));
    }
    
    /**
     * Mask all characters with stars.
     */
    public static String charToStars(String s) {
        return s.replaceAll(".","*");
    }
}
